﻿using System;
using System.IO;
using Microsoft.Xna.Framework.Audio;

namespace ThreeDWorld
{
    public class SoundReader : ContentTypeReader<SoundEffect>
    {
        public override SoundEffect Read(ContentReader reader)
        {
            MemoryStream stream = null;
            SoundEffect sound = null;

            try
            {
                sound = SoundEffect.FromStream(stream = new MemoryStream(reader.ReadByteArray()));
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                }
            }
            return sound;
        }
    }
}
